#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include<vector>
#include<map>

using namespace std;

int similarPairs(vector<string>& words) {
    map<vector<bool>, int> m;
    int res = 0;
    for (auto s : words)
    {
        vector<bool> t(26);
        for (auto c : s)
            t[c - 'a'] = true;
        res += m[t];
        m[t]++;
    }
    return res;
}

int similarPairs(vector<string>& words) {
    map<int, int> m;
    int res = 0;
    for (auto s : words)
    {
        int mask = 0;
        for (auto c : s)
            mask |= 1 << (c - 'a');
        res += m[mask];
        m[mask]++;
    }
    return res;
}